package com.psbc.queue;

import lombok.Builder;
import lombok.Data;

import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * @author:y022 12/06/2022 11:11
 * @description:
 */
public class PriorityDequePractice {

    public static void main(String[] args) {
//        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(Collections.reverseOrder());
//        priorityQueue.addAll(List.of(2, -4, 12, 5, 656, 43, 2314, 1));
//        while (!priorityQueue.isEmpty()) {
//            System.out.println(priorityQueue.poll());
//        }

        PriorityQueue<Consumer> consumerPriorityQueue = new PriorityQueue<>(Comparator.comparingInt(o -> o.getId().intValue()));

        consumerPriorityQueue.add(Consumer.builder().id(12L).name("AA").build());
        consumerPriorityQueue.add(Consumer.builder().id(-12L).name("BB").build());
        consumerPriorityQueue.add(Consumer.builder().id(14L).name("CC").build());

        while (!consumerPriorityQueue.isEmpty()) {
            System.out.println(consumerPriorityQueue.poll());
        }
    }

    @Builder
    @Data
    static class Consumer {
        private Long id;
        private String name;
    }
}
